<?php
    defined('_JEXEC') or die(); 
    JHTML::_('behavior.tooltip'); 
    $listOrder    = @$this->lists['order'];
    $listDirn    = @$this->lists['order_Dir'];
?>
<style>
    #tbl_filter{
        margin: 0 ; padding: 0 ;
    }
    
    #tbl_filter td{
        padding: 3px;
    }
    
    #tbl_filter input, #tbl_filter img {
        float: left;
        margin: 0 5px 0 0;
        width: auto;
    }
</style>
<link rel="stylesheet" type="text/css" href="<?php echo JURI::root(); ?>js/multiselect/jquery.multiselect.css" />
<link rel="stylesheet" type="text/css" href="<?php echo JURI::root(); ?>js/multiselect/jquery-ui.css" />
<script type="text/javascript" src="<?php echo JURI::root(); ?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo JURI::root(); ?>js/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?php echo JURI::root(); ?>js/multiselect/jquery.multiselect.js"></script>

<script type="text/javascript">

    function submitform(pressbutton){
        var form = document.adminForm ;
        if (pressbutton)
        {
            form.task.value=pressbutton ;
        }
        if ((pressbutton=='send_redemp_notice_email')||(pressbutton=='send_redemp_pick_up_notice')){
              form.controller.value="reports" ;
        }
        form.submit();
    }
    
    jQuery(function(){
        jQuery("#pick_up_at").multiselect({
            selectedList: 0,
            noneSelectedText: 'Select outlet',
            selectedText: "# of # selected"
        });
    });
</script>
<div class="row-fluid">    
	<?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
	<?php else : ?>
		<div id="j-main-container">
	<?php endif;?>
		<br clear="all">	
        <div class="alert">
            <form action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="filterform" >
                <table style='margin-bottom:5px' id="tbl_filter">
                    <tbody>
                        <tr>
                            <td align="left" width="35%"  valign="bottom" style="border-right: 1px solid #d0d0d0;">
                                <table >
                                    <tr valign="top">
                                        <td valign="top" width='35px'>From</td>        
                                        <td valign="top" width='150px'>
                                            <?php
                                                echo JHTML::_ ( 'calendar', ($this->pr['date_from'] != '') ? $this->pr['date_from'] : date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y'))), 'date_from', 'date_from', '%Y-%m-%d');
                                            ?>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td width='35px'>To</td>        
                                        <td width='150px'>
                                            <?php
                                                echo JHTML::_ ( 'calendar', ($this->pr['date_to'] != '') ? $this->pr['date_to'] : date('Y-m-d', time()), 'date_to', 'date_to', '%Y-%m-%d');
                                            ?>
                                        </td>
                                      
                                    </tr>
                                </table>
                            </td>
                            <td align="left" valign="bottom" style="border-right: 1px solid #d0d0d0;">
                                <table >
                                    <tr>
                                        <td>
                                             Outlet: 
                                        </td>
                                        <td style="width: 236px;">
                                            <?php echo $this->lists['filter_pick_up_outlet'] ; ?>                                            
                                        </td>
                                    </tr>
                                    <tr>
                                        
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left ;">
                                            <input type="submit" name="view" onclick="document.getElementById('submitViewExcel').value = 'submitViewExcel'; document.getElementById('task').value = 'exportpendinguser';" value="View" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td align="left" valign="bottom">
                                <table >
                                    <tr>
                                        <td>
                                            Choose: 
                                            <select name="topDisplaySelect" id="topDisplaySelect">
                                                <option value="10">10</option>
                                                <option value="20">20</option>
                                                <option value="50">50</option>
                                                <option value="100">100</option>
                                                <option value="">All</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            </select>&nbsp;or type&nbsp;
                                            <input name="topDisplaytbx" id="topDisplaytbx" type="text" style="width: 60px; float: none;" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: left ;padding: 10px 0 0;">                                            
                                            <input type="submit" id="exportexcel" name="exportexcel" onclick="document.getElementById('task').value = 'excelpendinguser'" value="Export excel" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
                
                <input type="hidden" name="controller" value="reports" />
                <input type="hidden" name="option" value="com_wrd" />
                <input type="hidden" name="submitViewExcel" id="submitViewExcel" value="" />
                <input type="hidden" name="task" id="task" value="" />
            </form>    
            </div>
            <br clear="all">
            <form id="adminForm"  action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" >
                <table class="adminlist table">
                    <thead>
                        <tr>
                            
                            <th nowrap="nowrap" width="12%">  
                                 Name
                             </th>
                            <th nowrap="nowrap" width="6%">
                                Member ID
                             </th>        
                             <th nowrap="nowrap" width="7%">  
                                 Phone
                             </th>
                             <th nowrap="nowrap" width="5%">  
                                 Job
                             </th> 
                             <th nowrap="nowrap" width="15%">  
                                 Company name
                             </th>
                             <th nowrap="nowrap" width="10%">  
                                 Outlet
                             </th>   
                             <th nowrap="nowrap" width="8%">  
                                 Total Visit
                             </th>                                                       
                             <th nowrap="nowrap" width="8%">  
                                 Total Spend
                             </th>   
                             <th nowrap="nowrap" width="8%">  
                                 Points
                             </th>                                                                             
                             <th nowrap="nowrap" width="8%">  
                                 Food
                             </th>                             
                             <th nowrap="nowrap" width="5%">  
                                 BV
                             </th>   
                             <th nowrap="nowrap" width="5%">  
                                  Misc
                             </th>   
                             
                        </tr>
                    </thead>
                    <tbody>
                         <?php
                               $k = 0;
                               if(count($this->items) > 0): 
                                for ($i=0, $n= count( $this->items ); $i < $n; $i++):
                                    $row = &$this->items[$i];
                                    $checked     = JHTML::_('grid.checkedout',   $row, $i);
									$p_o_u = WrdHelper::getPoints($row->user_id);
									
                            ?>    
                                 <tr class="<?php echo "row$k"; ?>" >
                                   
                                    <td>
                                        <a href="index.php?option=com_wrd&controller=profile&id=<?php echo $row->profile_id ?>&layout=form">
                                            <?php echo $row->l_name.' '.$row->f_name; ?>
                                        </a>
                                    </td>
                                    <td>
                                        <?php echo $row->vip_number; ?>
                                    </td>                          
                                    <td>
                                        <?php echo $row->phone; ?>
                                    </td>
                                    <td>
                                        <?php echo $row->job; ?>
                                    </td>
                                    <td>
                                        <?php echo $row->company; ?>
                                    </td>
                                    <td>
                                        <?php echo $row->outlet; ?>
                                    </td>
                                    <td>
                                        <?php echo $row->total_visit; ?>
                                    </td>                                
                                    <td>
                                        <?php echo number_format($row->total, 0, ',', ','); ?>
                                    </td>
                                    <td>
                                        <?php 
											echo $p_o_u->point;
										?>
                                    </td>
                                    <td>
                                        <?php echo $row->food; ?>
                                    </td>
                                    <td>
                                        <?php echo $row->beverage; ?>
                                    </td>
                                    <td>
                                        <?php echo $row->other; ?>
                                    </td>
                                 </tr>
                             <?php 
                                 $k = 1 - $k ;     
                                 endfor; 
                                 endif; 
                             ?>
                         </tbody>
                     <tfoot>
                        <tr>
                            <td colspan="16">
                                <?php
                                     echo $this->pagination->getListFooter();
                                ?>
                            </td>
                        </tr>
                    </tfoot>
                </table>
                <input type="hidden" name="controller" value="reports" />
                <input type="hidden" name="option" value="com_wrd" />
                <input type="hidden" name="task" value="exportpendinguser" />
                <input type="hidden" name="boxchecked" value="0" />
                <?php echo JHTML::_( 'form.token' ); ?>
            </form>
        </div>
</div>